package com.cloudsigns.factorymanager2.produce.presenter.produce_team;

import android.os.Handler;

import com.cloudsigns.factorymanager2.produce.iview.produce_team.IHandOverOrderListView;
import com.cloudsigns.factorymanager2.produce.model.produce_team.HandOverOrderListModel;
import com.cloudsigns.factorymanager2.produce.model.produce_team.IHandOverOrderListModel;

public class HandOverOrderListPresenter {
    private IHandOverOrderListView view;
    private IHandOverOrderListModel model;
    private Handler handler = new Handler();

    public HandOverOrderListPresenter(IHandOverOrderListView view) {
        this.view = view;
        this.model = new HandOverOrderListModel();
    }

    public void handOverOrderList() {
        model.handOverOrderList(view.getWorkPartOrderId(), new HandOverOrderListModel.OnHandOverOrderListListener() {
            @Override
            public void successed() {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.handOverOrderListSuccessed();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void failed(final String desc) {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.handOverOrderListFailed(desc);
                    }
                });
            }
        });
    }
}
